<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends BackController {
	/**
	 * 网站基础设置  
	 */
    public function index(){
		$post = IS_POST;
		if($post) {
			$setting = D('setting')->msave(); //修改网站基础设置
			if($setting) { // 修改成功
				$this->success('修改成功！',U('Index/index'));
			} else { // 修改失败
				$this->error('修改失败！');
			}
			die();
		} 

		$info = D('setting')->find();
		
		$this->assign('info',$info);
		$this->display();
    }

	/**
	 * 修改密码
	 */
	public function password() {
		$post = IS_POST;
		if($post) {
			$model = D('admin');
			if (!$model->create()){ //自动验证
			  $this->error($model->getError());
			  die();
			}
			$msg = $model->editpassword(); //修改密码
			if(!empty($msg)) {
				$this->success('修改成功！',U('Index/password'));
			} else {
				$this->error('修改失败！');
			}
			die();
		}
		$this->display();
	}
}
